<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="author" content="CarlHuang">
<title>兑奖点管理</title>
<script language="javascript" src="../script/common.js"
	type="text/javascript"></script>
<script language="javascript" type="text/javascript">
	   		var org = Common.cOrg()
	   		
			var qt = {};
			var qt2 = {};
			var qt3 ={};
			var qt4 ={};
			function load(){
			   Eui.showNavigation();
			   	var r=getPara("id");
			   setPages(["listview1","listview2"]);
	// switchPage("listview1");
			   
				  
			 	
			}
			
			function change10(){
			   Common.initSql($("mainform").level200,"org_dj_top",{},"0","1","全 部")
			}
			function change20(){
			   Common.initSql($("mainform").level500,"org_dj_top200",{},"0","1","全 部")
			}
			function change30(){
			   Common.initSql($("mainform").level2001,"org_dj_dq",{},"0","1","全 部")
			   Common.initSql($("mainform").level5001,"org_dj_ds",{},"0","1","全 部")
			   Common.initSql($("mainform").level7001,"org_dj_djd",{},"0","1","全 部")
			}
			var orgidp;
			function change31(s){
		
			          Common.initSql($("mainform").level5001,"org_dj_ds",{dqid:s},"0","1","全部");   
			          orgidp=s;
			          Common.initSql($("mainform").level7001,"org_dj_djd",{dqid:s},"0","1","全部");	
			}
			function change32(s){
		
			     if(s){
			          Common.initSql($("mainform").level7001,"org_dj_djd",{dsid:s},"0","1","全部");
					DWR.call("giftStorageService.getParentOrg",s,function(v){
						$("level2001").value=v.id;	
					});
				}else if(!s &&!orgidp){
					Common.initSql($("mainform").level7001,"org_dj_djd",{dsid:s},"0","1","全部");
				}else if(!s&&orgidp){
			         
			            Common.initSql($("mainform").level7001,"org_dj_djd",{dqid:orgidp},"0","1","全部");
				}else{
				
				}
			}
			function change33(s){
		
			     if(s){
			       	DWR.call("giftStorageService.getParentOrg",s,function(v){
			  	
						$("level5001").value=v.id;	
						DWR.call("giftStorageService.getParentOrg",v.id,function(v){
						$("level2001").value=v.id;	
					});
					});		
			     }
			}
				function a01change(){
			if($("A01").checked){
			change10();
			$("level200").disabled=false;
			$("level500").disabled=true;
		     $("level2001").disabled=true;
			$("level5001").disabled=true;
			$("level7001").disabled=true;
			$("level200").value="";
			$("level500").value="";
		     $("level2001").value="";
			$("level5001").value="";
			$("level7001").value="";
			}else if($("A02").checked)
			{
			change20();
			$("level200").disabled=true;
			$("level500").disabled=false;
		     $("level2001").disabled=true;
			$("level5001").disabled=true;
			$("level7001").disabled=true;
			$("level200").value="";
			$("level500").value="";
		     $("level2001").value="";
			$("level5001").value="";
			$("level7001").value="";
			}else{
			change30();
			$("level200").disabled=true;
			$("level500").disabled=true;
		     $("level2001").disabled=false;
			$("level5001").disabled=false;
			$("level7001").disabled=false;
			$("level200").value="";
			$("level500").value="";
		     $("level2001").value="";
			$("level5001").value="";
			$("level7001").value="";
			}
			}
			
			//设置表格数据列
			function createTable(){
				var columns = [];
			  columns[5]={title:"操作",width:"9%",align:"center",render:stop,order:false}
						qt = new QueryTable("dpi_add","mainform","datalist",columns,{
				buttons:[
						{value:"增 加",actions:onNew}
						]
				});
				
				
			}
			function createTable2(){
			    var columns = [];
			    columns[0]={type:"checkbox"};
				qt2 = new QueryTable("dpi_add2","mainform2","datalist2",columns,{
				buttons:[
						{value:"启 用",actions:init}
						]
				});
	            qt2.showTable();
				
				
			}
			function createTable5(){
			    var columns = [];
			    columns[0]={type:"checkbox"};
				qt2 = new QueryTable("dpi_add5","mainform2","datalist2",columns,{
				buttons:[
						{value:"启 用",actions:init}
						]
				});
	            qt2.showTable();
				
				
			}
			function createTable6(){
			    var columns = [];
			    columns[0]={type:"checkbox"};
				qt2 = new QueryTable("dpi_add6","mainform2","datalist2",columns,{
				buttons:[
						{value:"启 用",actions:init}
						]
				});
	            qt2.showTable();
				
				
			}
			
			function createTable3(){
				var columns = [];
			  columns[5]={title:"操作",width:"9%",align:"center",render:stop,order:false}
						qt3 = new QueryTable("dpi_add3","mainform","datalist",columns,{
				buttons:[
						{value:"增 加",actions:onNew}
						]
				});
				
				
			}
			
			function createTable4(){
				var columns = [];
			  columns[5]={title:"操作",width:"9%",align:"center",render:stop,order:false}
						qt4 = new QueryTable("dpi_add4","mainform","datalist",columns,{
				buttons:[
						{value:"增 加",actions:onNew}
						]
				});
				
				
			}
			
			function stop(v,r){
			 return	"<a href=# onclick=\"tingyong("+r[0]+");return false;\">停用</a>" 
			}
			
			function back(){
			createTable();
			 switchPage('listview1');
			 qt.showTable();	
			}
			function init(){
			 var	id = qt2.getBoxValue();
	        if(id==null||id==""){
          showWarning("请选择要启动的兑奖点");return;
           }
	  
	  
			if(showQuestion("确定要增加该机构为兑奖点吗?")==false){
			    return;
				} 
				var ids = id.split(",");
			 DWR.call('	giftProjectService.startGiftLocation',ids,function(v){
			   showInformation("启用成功!");
	        switchPage('listview2');
	         createTable2();
	         qt2.showTable();
	        });
	        }
	        
			function tingyong(id){
			if(showQuestion("确定要停用此兑奖点吗?")==false){
			    return;
				} 
			 DWR.call('	giftProjectService.stopGiftLocation',id,function(v){
			   showInformation("停用成功!");
	         showData();
	        switchPage('listview1');
	        });
			}
			
			function onNew(){
			 switchPage("listview2");
				// createTable2();
			
			}
			
			//显示、刷新表格
			function showData(){
				  if($("A03").checked)
					{
					 createTable();
					qt.showTable();}
					else if($("A02").checked)
					 	{ 
					 	createTable3();
					 	qt3.showTable();}
					 	else if($("A01").checked)
					 	{ 
					 	createTable4();
					 	qt4.showTable();
					 	}
					 	else{
					 	alert("请选择机构类型");
					 	}
			}
			function showData2(){
					 if($("A06").checked)
					{
					 createTable2();
					qt2.showTable();}
					else if($("A05").checked)
					 	{ 
					 	createTable5();
					 	qt5.showTable();}
					 	else if($("A04").checked)
					 	{ 
					 	createTable6();
					 	qt6.showTable();
					 	}
					 	else{
					 	alert("请选择机构类型");
					 	}
			}
			function onSave() {
				var v = getBackValue();
				dialogBackValue(v);
			}
			function change10b(){
			   Common.initSql($("mainform2").level200b,"org_dj_topb",{},"0","1","全 部")
			}
			function change20b(){
			   Common.initSql($("mainform2").level500b,"org_dj_top200b",{},"0","1","全 部")
			}
			function change30b(){
			   Common.initSql($("mainform2").level2001b,"org_dj_dqb",{},"0","1","全 部")
			   Common.initSql($("mainform2").level5001b,"org_dj_dsb",{},"0","1","全 部")
			   Common.initSql($("mainform2").level7001b,"org_dj_djdb",{},"0","1","全 部")
			}
			var ds;
			var orgidp2;
			function change31b(s){
			          Common.initSql($("mainform2").level5001b,"org_dj_dsb",{dqid:s},"0","1","全部");   
			          orgidp2=s;
			          Common.initSql($("mainform2").level7001b,"org_dj_djdb",{dqid:s},"0","1","全部");	
			}
			function change32b(s){
			     if(s){
			          Common.initSql($("mainform2").level7001b,"org_dj_djdb",{dsid:s},"0","1","全部");
					DWR.call("giftStorageService.getParentOrg",s,function(v){
						$("level2001b").value=v.id;	
					});
				}else if(!s &&!ds){
					Common.initSql($("mainform2").level7001b,"org_dj_djdb",{dsid:s},"0","1","全部");
				}else if(!s&&ds){
			         
			            Common.initSql($("mainform2").level7001b,"org_dj_djdb",{dqid:ds},"0","1","全部");
				}else{
				
				}
			}
			function change33b(s){
			     if(s){
			       	DWR.call("giftStorageService.getParentOrg",s,function(v){
			  	
						$("level5001b").value=v.id;	
						DWR.call("giftStorageService.getParentOrg",v.id,function(v){
						$("level2001b").value=v.id;	
					});
					});
					
			     }
			
			}
		
			function a01changeb(){
			if($("A04").checked){
			change10b();
			$("level200b").disabled=false;
			$("level500b").disabled=true;
		     $("level2001b").disabled=true;
			$("level5001b").disabled=true;
			$("level7001b").disabled=true;
			$("level200b").value="";
			$("level500b").value="";
		     $("level2001b").value="";
			$("level5001b").value="";
			$("level7001b").value="";
			}else if($("A05").checked)
			{
			change20b();
			$("level200b").disabled=true;
			$("level500b").disabled=false;
		     $("level2001b").disabled=true;
			$("level5001b").disabled=true;
			$("level7001b").disabled=true;
			$("level200b").value="";
			$("level500b").value="";
		     $("level2001b").value="";
			$("level5001b").value="";
			$("level7001b").value="";
			}else{
			change30b();
			$("level200b").disabled=true;
			$("level500b").disabled=true;
		     $("level2001b").disabled=false;
			$("level5001b").disabled=false;
			$("level7001b").disabled=false;
			$("level200b").value="";
			$("level500b").value="";
		     $("level2001b").value="";
			$("level5001b").value="";
			$("level7001b").value="";
			}
			}
		</script>
	</HEAD>
<body onload="load()">

    <div class=" nav "><div id="nav">&nbsp;</div></div>
    <div id="content"><!--查询静态页面部分-->
		<!--查询条件form-->
		<div id="listview1"><!--查询静态页面部分-->
		<div class="form">
			<form id="mainform" name="mainform">
				<input type="hidden" name="orgLocation">
				<input type="hidden" name="locationId">
				<div class="searchForm">
					<table cellSpacing=0 cellPadding=4 width="100%" border=0>
							    <tr><td><input type="radio" name="level" id="A01" onClick="a01change()">总部直属</input></td>
							        <td><label>兑奖点</label> <select name="level200" disabled></select></td> 
							    </tr>
							    <tr>
							    <td><input type="radio" name="level" id="A02" onClick="a01change()">省大区直属</input></td>
							    <td ><label>兑奖点</label> <select name="level500" disabled></select></td>
							    </tr>
							    <tr>
							    <td><input type="radio" name="level" id="A03" onClick="a01change()">地市</input></td>
							    <td><label>省大区</label> <select name="level2001" disabled  onClick="change31(this.value)"></select></td>
							    <td><label>地&nbsp;&nbsp;市</label> <select style="width:240px" name="level5001" disabled onClick="change32(this.value)"></select></td>
							    <td><label>兑奖点</label> <select style="width:240px" name="level7001" disabled onClick="change33(this.value)"></select></td>
					          
						</tr>
						<tr>
							<td></td><td></td><td></td><td></td><td><button type="button" onclick="showData()">查 询</button></td>
						</tr>
					</table>
					</div>
				
			
			</form>
		</div>
		<div id="datalist"></div>
	</div>
	</div>
	
<div id="listview2" style="display:none;">	
		<!--查询条件form-->
		<div class="form">
			<form id="mainform2" name="mainform2">
				<input type="hidden" name="orgLocation">
				<input type="hidden" name="locationId">
				<div class="searchForm2">
					<table cellSpacing=0 cellPadding=4 width="100%" border=0>
							    <tr><td><input type="radio" name="level" id="A04" onClick="a01changeb()">总部直属</input></td>
							        <td><label>机构</label> <select name="level200b" disabled></select></td> 
							    </tr>
							    <tr>
							    <td><input type="radio" name="level" id="A05" onClick="a01changeb()">省大区直属</input></td>
							    <td ><label>机构</label> <select name="level500b" disabled></select></td>
							    </tr>
							    <tr>
							    <td><input type="radio" name="level" id="A06" onClick="a01changeb()">地市</input></td>
							    <td><label>省大区</label> <select name="level2001b" disabled  onClick="change31b(this.value)"></select></td>
							    <td><label>地&nbsp;&nbsp;市</label> <select style="width:180px" name="level5001b" disabled onClick="change32b(this.value)"></select></td>
							    <td><label>机构</label> <select style="width:250px" name="level7001b" disabled onClick="change33b(this.value)"></select></td>
					          
						</tr>
						<tr>
							<td></td><td></td><td></td><td></td><td><button type="button" onclick="showData2()">查 询</button>
							<button type="button" onclick="back()">返回</button></td>
						</tr>
					</table>
					</div>
		
			</form>
		</div>
		<div id="datalist2"></div>
	</div>
</BODY>
</HTML>